import { Entity, JoinColumn, OneToOne } from "typeorm";
import { BaseToken } from "./base.token";
import { AccessTokenEntity } from "./access-token.entity";

@Entity('user_refresh_tokens')
export class RefreshTokenEntity extends BaseToken {
    /**
     * @description 关联的登录令牌
     * @type {AccessTokenEntity}
     */
    @OneToOne(() => AccessTokenEntity, (accessToken) => accessToken.refreshToken, {
        onDelete: 'CASCADE',
    })
    @JoinColumn()
    accessToken!: AccessTokenEntity;
}